package vn.com.fsoft.model.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;

@Entity
@Table(name = "COUNTY")
public class County implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2255340667138999708L;
	private int countyId;
	private Country countryCounty;
	private String countyName;
	private Set<Town> towns = new HashSet<Town>(0);

	private Set<GovOfficeRegion> govOfficeRegion = new HashSet<GovOfficeRegion>(0);

	public County() {
		super();
	}

	public County(int countyId, Country countrys, String countyName) {
		super();
		this.countyId = countyId;
		this.countryCounty = countrys;
		this.countyName = countyName;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "COUNTY_ID", unique = true, nullable = false)
	public int getCountyId() {
		return countyId;
	}

	public void setCountyId(int countyId) {
		this.countyId = countyId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "COUNTRY_ID", nullable = false)
	public Country getCountryCounty() {
		return countryCounty;
	}

	public void setCountryCounty(Country countrys) {
		this.countryCounty = countrys;
	}

	@Column(name = "COUNTY_NAME", length = 50, nullable = false)
	public String getCountyName() {
		return countyName;
	}

	public void setCountyName(String countyName) {
		this.countyName = countyName;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "countyTown")
	public Set<Town> getTowns() {
		return towns;
	}

	public void setTowns(Set<Town> town) {
		this.towns = town;
	}

	@ManyToMany
	@JoinTable(name = "COUNTYGOVOFFICE", joinColumns = { @JoinColumn(name = "CG_COUNTYID") }, inverseJoinColumns = { @JoinColumn(name = "CG_GOVOFFICEREGIONID") })
	public Set<GovOfficeRegion> getGovOfficeRegion() {
		return govOfficeRegion;
	}

	public void setGovOfficeRegion(Set<GovOfficeRegion> govOfficeRegion) {
		this.govOfficeRegion = govOfficeRegion;
	}
}
